/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package questionbook.model;

import java.text.SimpleDateFormat;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
import questionbook.manager.StoreManager;

/**
 * Holds the Properties that are needed by any model in the System
 *
 * @author stefanstift
 */
public class StandardModel {

    /**
     * the Unifrom Resource Identifier that is needed for every entity in the
     * Ontology in order to identify the node
     */
    private URI uri;

    protected SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");

    /**
     * Creates a new StandardModel instance with the specified URI
     *
     * @param uri
     */
    public StandardModel(URI uri) {
        this.uri = uri;
    }

    /**
     *  Creates a new StandardModel instance with the specified URI-String,
     *  The Store is needed to trasfer this String in a valid URI-Object
     *
     * @param uri
     */
    public StandardModel(String uri) {
        this.uri = StoreManager.getInstance().getStore().getURIref(uri);
    }

    /**
     *
     * @return the URI of this StandardModel instance
     */
    public URI getUri() {
        return uri;
    }

    /**
     * Sets the URI of this StandardModel instance
     *
     * @param uri
     */
    public void setUri(URI uri) {
        this.uri = uri;
    }

    /**
     *
     * @param s the String-Field that gets transferred in a Literal-Object
     * @return a Literal-Representation of a String (needed for the Sesame RDF-Model)
     */
    protected Literal getStringLiteral(String s)
    {
        return StoreManager.getInstance().getStore().getLiteral(s);
    }

     /**
     *
     * @param s the Long-Field that gets transferred in a Literal-Object
     * @return a Literal-Representation of a Long (needed for the Sesame RDF-Model)
     */
    protected Literal getLongLiteral(Long l)
    {
        return StoreManager.getInstance().getStore().getLiteral(l);
    }

    /**
     * Two instances are declared as equal, when they have the same URI
     *
     * @param obj
     * @return true if the Object equals this instance, false if not
     */
    @Override
    public boolean equals(Object obj) {

        StandardModel m = (StandardModel) obj;

        if(this.uri.stringValue().equals(m.getUri().stringValue()))
            return true;

        return false;

    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }


    


}
